#include "wx/wxprec.h"
#if wxUSE_STREAMS && wxUSE_PROTOCOL_FILE

#include "wx/uri.h"
#include "wx/wfstream.h"
#include "wx/protocol/file.h"

IMPLEMENT_DYNAMIC_CLASS( wxFileProto, wxProtocol )
IMPLEMENT_PROTOCOL( wxFileProto, wxT( "file" ), NULL, false )

wxFileProto::wxFileProto()
  : wxProtocol() {
  m_error = wxPROTO_NOERR;
}

wxFileProto::~wxFileProto() {
}

wxInputStream *wxFileProto::GetInputStream( const wxString& path ) {
  wxFileInputStream *retval = new wxFileInputStream( wxURI::Unescape( path ) );
  if( retval->Ok() ) {
    m_error = wxPROTO_NOERR;
    return retval;
  }
  m_error = wxPROTO_NOFILE;
  delete retval;
  return NULL;
}

#endif // wxUSE_STREAMS && wxUSE_PROTOCOL_FILE
